package com.example.roomandrlivedata.database;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;


import com.example.roomandrlivedata.bean.Student;

import java.util.List;

/**
 * @author: njb
 * @date: 2020/8/28 0028 0:17
 * @desc:学生dao
 */
@Dao
public interface StudentDao {
    @Insert
    void insertStudent(Student student);

    @Delete
    void deleteStudent(Student student);

    @Update
    void updateStudent(Student student);

    @Query("SELECT * FROM student")
    LiveData<List<Student>> getStudentList();//希望监听学生表的变化，为其加上LiveData

    @Query("SELECT * FROM student WHERE id = :id")
    Student getStudentById(int id);
}
